import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path,{ resolve } from 'path'
import styleImport from 'vite-plugin-style-import'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'vant',
          esModule: true,
          resolveStyle: (name) => `vant/es/${name}/style`,
        },
      ],
    }),
  ],
  resolve:{
    alias:{
      "@":resolve(__dirname,"./src"),
      "pages":resolve(__dirname,"./src/pages"),
      "utils":resolve(__dirname,"./src/utils"),
      "assets":resolve(__dirname,"./src/assets"),
      "api":resolve(__dirname,"./src/api"),
      "components":resolve(__dirname,"./src/components")
    }
  },
  server:{
    host: "0.0.0.0",
    port: 8080,
    proxy:{
      "/api":{
        target:"ws://ttapi.research.itcast.cn",
        changeOrigin:true,
        ws:true,
        rewrite:path => path.replace(/^\/api/,'')
      }
    }
  },
  build:{
    sourcemap:false
  }
})
